<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <!-- html里不要驼峰命名 不识别大小写的-->
        <product-item></product-item>
        <home-nav></home-nav>
    </div>
    <template id="product">
        <div class="product">
            <h2>商品描述：{{title}}</h2>
            <p>价格:{{price}}</p>
        </div>
    </template>
    <template id="nav">
        <p>分割下-------------------</p>
        <h2>{{message}}</h2>
        <product-item></product-item>
        <p>分割下-------------------</p>
    </template>
    <script src="https://unpkg.com/vue@next"></script>
    <script>
        const ProductItem = {
            template: "#product",
            data() {
                return {
                    title: "局部组件",
                    price: 3.42
                }
            }
        }
        const app = Vue.createApp({
            components: {
                // js里不要加-命名
                ProductItem,
                HomeNav: {
                    template: "#nav",
                    // 在HomeNav里嵌套一个ProductItem组件
                    components: {
                        ProductItem
                    },
                    data() {
                        return {
                            message: "我是导航栏",
                        }
                    }
                }
            },
            data() {
                return {
                    message: "Hello world"
                }
            },

        })
        //挂载app
        app.mount("#app")
    </script>

</body>

</html>